#include "Branch.h"
#include "MetaDataIO.h"
#include "DataDefine.h"

namespace gitstore {
CBranchOperation::CBranchOperation() {

}

CBranchOperation::~CBranchOperation() {

}

ErrorStatus CBranchOperation::load(std::shared_ptr<CMetaDataIOBase> io_worker, const std::string& ds_name, const std::string& br_name, Branch& branch) {
    return io_worker->loadBranch(ds_name, br_name, branch);
}

ErrorStatus CBranchOperation::dump(std::shared_ptr<CMetaDataIOBase> io_worker, const Branch& branch) {
    return io_worker->saveBranch(branch);
}

ErrorStatus CBranchOperation::setVersion(Branch& branch, const std::string& version) {
    branch.cur_version = version;
    return Success;
}

ErrorStatus CBranchOperation::create(const std::string& ds_name, const std::string& br_name, const std::string& br_note, const std::string& version, int type, Branch& branch) {
    branch.ds_name = ds_name;
    branch.name = br_name;
    branch.note = br_note;
    branch.type = type;
    branch.cur_version = version;
    time_t t;
    t=time(&t);
    branch.date = t;
    return Success;
}

}
